package com.smart.admin.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * .............................................
 * When I wrote this, only God and I understood what I was doing
 * Now, God only knows
 * .............................................
 *
 * @ProjectName: spring-boot-demo
 * @Package: com.smart.common.config
 * @ClassName: MybatisPlusConfig
 * @Description: 描述
 * @Author: zhangwei
 * @CreateDate: 2021/12/10 10:45
 * @UpdateUser: 更新者
 * @UpdateDate: 2021/12/10 10:45
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */

@Configuration
public class MybatisPlusConfig {
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
        // 分页
        PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();
        paginationInnerInterceptor.setOverflow(true);
        paginationInnerInterceptor.setMaxLimit(50L);
        // 乐观锁

        OptimisticLockerInnerInterceptor optimisticLockerInnerInterceptor = new OptimisticLockerInnerInterceptor();


        mybatisPlusInterceptor.addInnerInterceptor(paginationInnerInterceptor);
        mybatisPlusInterceptor.addInnerInterceptor(optimisticLockerInnerInterceptor);

        return mybatisPlusInterceptor;
    }


}
